/**
 *  @file vector2.h
 *
 *  @date Oct 20, 2009
 *  @author Ives van der Flaas
 */

#ifndef VECTOR2_H_
#define VECTOR2_H_

#include <iostream>
namespace si
{
/**
 * 2 dimensional vector class that uses doubles.
 */
  class Vector2
  {
    public:
      Vector2();
      Vector2(const double x, const double y);
      Vector2(const Vector2&);
      Vector2 operator=(const Vector2&);

      Vector2 operator-(const Vector2&) const;
      Vector2 operator+(const Vector2&) const;

      Vector2 operator+(const double& d) const;
      Vector2 operator-(const double& d) const;
      Vector2 operator*(const double& d) const;
      Vector2 operator/(const double& d) const;

      Vector2 operator-=(const double& d);
      Vector2 operator+=(const double& d);
      Vector2 operator*=(const double& d);
      Vector2 operator/=(const double& d);

      Vector2& operator+=(const Vector2& v);

      Vector2 operator-() const;
      Vector2 operator+() const;

      bool operator==(Vector2& v) const;
      bool operator!=(Vector2& v) const;

      double dotProduct(const Vector2& v2) const;

      inline double getX() const  	{  		return fx;  	}
      inline double getY() const	{  		return fy;  	}

      inline void setX(const double x){  		fx = x;  	}
      inline void setY(const double y){  		fy = y;  	}

      void normalize();
      double length() const;

    private:
      double fx, fy;


  };

  Vector2 operator*(const double& d, const Vector2& v);
  std::ostream& operator<<(std::ostream& os, Vector2& v);
}

#endif /* VECTOR2_H_ */
